import { CGraphEntity } from 'stores/editorModels';

//如果需要手动映射type和组件的关系，请在这里配置
const viewRegisterMap = {
  'tuple-text': 'view-tuple-basic',
  'tuple-line': 'view-tuple-basic',
  'tuple-line-arrow': 'view-tuple-basic', // ’-‘进行驼峰转换
  'tuple-rect': 'view-tuple-basic',
  'tuple-triangle': 'view-tuple-basic',
  'tuple-circle': 'view-tuple-basic',
  'tuple-double-circle': 'view-tuple-basic',
  'tuple-ellipse': 'view-tuple-basic',
  'tuple-equal-polygon': 'view-tuple-basic',
  'tuple-image': 'view-tuple-image',
  'tuple-table': 'view-tuple-table',

  'media-video': 'view-media-video',
  'media-audio': 'view-media-audio',
  'media-website': 'view-media-website',

  'chart-line': 'view-chart-line',
  'chart-curve': 'view-chart-curve',
  'chart-bar': 'view-chart-bar',
  'chart-scatter': 'view-chart-scatter',
  'chart-pie': 'view-chart-pie',
  'chart-arc': 'view-chart-arc',
  'chart-gauge': 'view-chart-gauge',
  'chart-simple-gauge': 'view-chart-simple-gauge',
  'chart-map': 'view-chart-map',

  'form-variable': 'view-form-variable',
  'form-text-variable': 'view-form-variable-input',
  'form-toggle': 'view-form-toggle',
  'form-circular-progress': 'view-form-circular-progress',
  'form-linear-progress': 'view-form-linear-progress',
  'form-button': 'view-form-button',
  'form-toggle-button': 'view-form-toggle-button',
  'form-knob-button': 'view-form-knob-button',

  'animation-rotate': 'view-animation-rotate',
  'animation-rotate-icon': 'view-animation-rotate-icon',
  'animation-twinkle': 'view-animation-winkle',
  'animation-flow': 'view-animation-flow',

  'recycling_water_tank': 'view-recycling-water-tank'
};

//优先匹配map，否则将自动匹配
export  function parseViewName (component: CGraphEntity) {
  let viewName :string = '';
  if (Object.prototype.hasOwnProperty.call(viewRegisterMap, component.comValue) === false) {
    console.info(
      `没有手动配置组件映射，将根据数据的type自动匹配，当前组件类型=${component.comValue}`
    );
    viewName = 'view-' + component.comValue;
  } else {
    // keyof typeof
    viewName = viewRegisterMap[component.comValue as keyof typeof viewRegisterMap];
    //console.info(viewName);
  }
  return viewName;
}
